<template>
  <input type="text" v-model="guessNum">
  <button @click="guess()">猜测</button>
  <p>{{result}}</p>
  <input type="text" :value="num">
</template>

<script setup>
import {ref} from "vue";
const num=parseInt(Math.random()*100)+1;
const guessNum=ref('');
const result=ref('');
const guess=()=>{
  if (guessNum.value>num){
    result.value='猜大了';
  }else if (guessNum.value<num){
    result.value='猜小了';
  }else
    result.value='猜对了';
}
</script>

<style scoped>

</style>